<template>
  <div>

    <el-form ref="form" :inline="true" :model="sfForm" label-width="300px">
      <el-form-item label="收房合同编号">
        <el-input disabled v-model="sfForm.sfContractNo"></el-input>
      </el-form-item>
      <el-button type="warning" @click="searchSfList()">收房合同查询</el-button><br>
      <el-form-item label="房产信息">
        <el-input disabled v-model="sfForm.houseName"></el-input>
      </el-form-item><br>
      <el-form-item label="业主姓名">
        <el-input disabled v-model="sfForm.ownerName"></el-input>
      </el-form-item>
      <el-form-item label="业主手机号">
        <el-input disabled v-model="sfForm.ownerMobile"></el-input>
      </el-form-item><br>
      <el-form-item label="业主身份证号">
        <el-input disabled v-model="sfForm.ownerIdCard"></el-input>
      </el-form-item>
      <el-form-item label="银行卡号">
        <el-input disabled v-model="sfForm.bankCard"></el-input>
      </el-form-item><br>
      <el-form-item label="银行名称">
        <el-input disabled v-model="sfForm.bankName"></el-input>
      </el-form-item>
      <el-form-item label="开户行">
        <el-input disabled v-model="sfForm.bankOpen"></el-input>
      </el-form-item><br>
      <el-form-item label="金融产品选择">
        <el-select v-model="jrProductId" value-key="id" placeholder="请选择" @change="handleProduct">
          <el-option v-for="item in products" :key="item.id" :label="item.jrProductName" :value="item"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="年利率">
        <el-input v-model="sfForm.rate"></el-input>
      </el-form-item><br>
      <el-form-item label="借款期限">
        <el-input v-model="sfForm.monthLimit"></el-input>
      </el-form-item>
      <el-form-item label="年一次性服务费率">
        <el-input v-model="sfForm.serviceFee"></el-input>
      </el-form-item><br>
      <el-form-item label="借款金额">
        <el-input disabled v-model="sfForm.sxBalance"></el-input>
      </el-form-item>
      <el-form-item label="授信额度">
        <el-input disabled style="width: 80px" v-model="sfForm.name"></el-input>%
      </el-form-item><br>
      <el-form-item label="备注">
        <el-input type="textarea" :rows="5" style="width: 300px" v-model="sfForm.remark"></el-input>
      </el-form-item>
      <div align="center">
        <el-form-item>
          <el-button type="primary" @click="">提交申请</el-button>
        </el-form-item>
      </div>
    </el-form>

    <el-dialog
      title="收房合同信息"
      :visible.sync="sfDialog"
      width="40%"
      center>
      <el-table :data="sfData" border style="width: 100%">
        <el-table-column prop="ownerName" label="业主姓名" width="180"></el-table-column>
        <el-table-column prop="houseName" label="房产信息" width="180"></el-table-column>
        <el-table-column prop="conSignTime" label="签约时间"></el-table-column>
        <el-table-column fixed="right" label="操作">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" style="color: #ffa800" size="small">选中</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-dialog>


  </div>
</template>

<script>
export default {
  name: "Installment",
  data() {
    return {
      jrProductId:{},
      products:[],
      total:0,
      sfDialog:false,
      sfForm:{},
      sfData:[],
      pageNum:1,
      pageSize:5
    }
  },
  created() {
      this.initProduct();
  },
  methods:{
    handleProduct() {
      this.sfForm.monthLimit = this.jrProductId.instalmentPeriod
    },
    initProduct() {
      this.axios.get('http://localhost:9999/financial-service/tJrProduct/searchSfProduct').then((res=>{
        this.products = res.data.obj
        console.log(this.products)
      }))
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
      this.searchSfList();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.pageNum = val
      this.searchSfList()
    },
    handleClick(row) {
      this.sfDialog = false
      this.axios.get('http://localhost:9999/financial-service/tJrSfLoan/searchSfById',{
        params:{
          sfContractId:row.id
        }
      }).then((res=>{
        this.sfForm = res.data.obj
        console.log(res.data.obj)
      }))
    },
    searchSfList() {
      this.axios.post('http://localhost:9999/financial-service/tJrSfLoan/searchSfAll',{
        pageNum:this.pageNum,
        pageSize:this.pageSize
      }).then((res=>{
        this.sfData = res.data.obj.list
        this.total = res.data.obj.total
        this.sfDialog = true;
      }))
    }
  }
}
</script>

<style scoped>

</style>
